package distanciaedicion;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.*;


public class Parser {
	private BufferedReader bufferedReader = null;
	public  ArrayList<Integer> parsear(String path) throws IOException {
		ArrayList<Integer> costos = new ArrayList<Integer>(Settings.CANTIDAD_OPERACIONES);
		System.out.println(Settings.CANTIDAD_OPERACIONES);
		System.out.println("costos size " + costos.size());
		if (bufferedReader == null)
			bufferedReader = new BufferedReader(new FileReader(path));
		String line = new String();
		line = bufferedReader.readLine();
		while (line != null) {
			System.out.println(line);
			if (line.indexOf("Borrar") != -1)
				costos.add(Settings.INDICE_COSTO_BORRADO, 
						new Integer (line.substring(line.length() - 1,
						line.length())));
			if (line.indexOf("Copiar") != -1)
				costos.add(Settings.INDICE_COSTO_COPIAR, 
						new Integer (line.substring(line.length() - 1,
						line.length())));
			if (line.indexOf("Insertar") != -1)
				costos.add(Settings.INDICE_COSTO_INSERCION, 
		new Integer (line.substring(line.length() - 1,
						line.length())));
			if (line.indexOf("Intercambiar") != -1)
				costos.add(Settings.INDICE_COSTO_INTERCAMBIAR, 
						new Integer (line.substring(line.length() - 1,
						line.length())));
			if (line.indexOf("Reemplazar") != -1)
				costos.add(Settings.INDICE_COSTO_REEMPLAZAR, 
						new Integer (line.substring(line.length() - 1,
						line.length())));
			else costos.add(Settings.INDICE_COSTO_TERMINAR, new Integer (line.substring(line.length() - 1,
						line.length())));
			line = bufferedReader.readLine();			
			}
		bufferedReader.close();
		return costos;	
		//mississipi minessossi
	}
}
